package com.spa.infrastructure.mapper;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.spa.application.command.member.MemberFeedbackAddCommand;
import com.spa.application.dto.PageResult;
import com.spa.application.dto.member.MemberFeedbackDTO;
import com.spa.application.dto.shop.ShopFeedbackDTO;
import com.spa.application.query.member.MemberFeedbackQuery;
import com.spa.application.query.shop.ShopFeedbackQuery;
import com.spa.domain.entity.Feedback;
import com.spa.infrastructure.enums.dict.feedback.FeedbackTypeEnum;
import com.spa.infrastructure.repository.condition.FeedbackCondition;
import com.spa.infrastructure.repository.po.FeedbackPO;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 反馈表(Feedback) 映射结构类
 *
 * @author lig
 * @since 2024-01-11 10:51:23
 */
@Mapper
@MapperConfig(unmappedTargetPolicy = ReportingPolicy.WARN)
public interface FeedbackMapperStruct {

    FeedbackMapperStruct INSTANCE = Mappers.getMapper(FeedbackMapperStruct.class);

    Page<Feedback> po2Entity4Page(Page<FeedbackPO> po);

    List<Feedback> po2Entity4List(List<FeedbackPO> po);

    Feedback po2Entity(FeedbackPO po);


    @Named("int2Enum")
    default FeedbackTypeEnum int2Enum(int type) {
        return FeedbackTypeEnum.byCode(type);
    }


    //================用户端==start = ↓ ============
    FeedbackPO commandMember2Po(MemberFeedbackAddCommand command);

    @Mapping(source = "type", target = "type", qualifiedByName = "int2Enum")
    MemberFeedbackDTO entity2MemberDto(Feedback entity);

    PageResult<MemberFeedbackDTO> entity2MemberDto4Page(Page<Feedback> entity);

    FeedbackCondition memberQuery2Condition(MemberFeedbackQuery query);

    //================用户端==end = ↑ ============




    //================门店端==start = ↓ ============

    FeedbackCondition shopQuery2Condition(ShopFeedbackQuery query);

    @Mapping(source = "type", target = "type", qualifiedByName = "int2Enum")
    ShopFeedbackDTO entity2ShopDto(Feedback entity);

    PageResult<ShopFeedbackDTO> entity2ShopDto4Page(Page<Feedback> entity);


    //================用户端==end = ↑ ============


}
